<!DOCTYPE html>
<html >
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .parent{
            width: 600px;
            height: 600px;
            border: 1px solid blue;
            margin: 20px auto;
            position: relative;
        }
        .box{
            width: 300px;
            height: 300px;
            background-color: red;
            position: absolute;
            left: 50%;
            top: 50%; 
            transform: translate(-50% -50%);
        }
    </style>
</head>
<body>
    <div class="parent">         
       <div class="box"></div>
    </div>
</body>
</html>